package com.fakepath.views;

import com.example.pathfake.Direction;
import com.example.pathfake.LayoutChangedListener;
import com.fakepath.animations.InOutAnimation;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.widget.FrameLayout;

public class InOutFrameLayout extends FrameLayout {
	private Animation animation;
	private LayoutChangedListener layoutChangedListener;

	public InOutFrameLayout(Context paramContext) {
		super(paramContext);
	}

	public InOutFrameLayout(Context paramContext, AttributeSet paramAttributeSet) {
		super(paramContext, paramAttributeSet);
	}

	protected void onAnimationEnd() {
		super.onAnimationEnd();
		if ((this.animation instanceof InOutAnimation)) {
			int i;
			if (((InOutAnimation) this.animation).direction != Direction.OUT) {
				i = View.VISIBLE;
			} else {
				i = View.GONE;
			}
			setVisibility(i);
		}
	}

	protected void onAnimationStart() {
		super.onAnimationStart();
		if ((this.animation instanceof InOutAnimation))
			setVisibility(View.VISIBLE);
	}

	protected void onLayout(boolean changed, int left, int top, int right,
			int bottom) {
		super.onLayout(changed, left, top, right, bottom);
		if ((changed) && (this.layoutChangedListener != null))
			this.layoutChangedListener
					.onLayoutChanged(left, top, right, bottom);
	}

	public void setLayoutChangedListener(
			LayoutChangedListener paramLayoutChangedListener) {
		this.layoutChangedListener = paramLayoutChangedListener;
	}

	public void startAnimation(Animation paramAnimation) {
		super.startAnimation(paramAnimation);
		this.animation = paramAnimation;
		getRootView().postInvalidate();
	}
}
